use thiserror::Error;

#[derive(Error, Debug)]
pub enum BuildMigrateError {
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("XML parsing error: {0}")]
    XmlParse(String),

    #[error("TOML parsing error: {0}")]
    TomlParse(#[from] toml::de::Error),

    #[error("Configuration error: {0}")]
    Config(String),

    #[error("Parser error: {0}")]
    Parser(String),

    #[error("Generator error: {0}")]
    Generator(String),

    #[error("Unsupported file format: {0}")]
    UnsupportedFormat(String),

    #[error("Project structure error: {0}")]
    ProjectStructure(String),

    #[error("Script execution error: {0}")]
    ScriptExecution(String),
}

impl From<xml::reader::Error> for BuildMigrateError {
    fn from(err: xml::reader::Error) -> Self {
        BuildMigrateError::XmlParse(err.to_string())
    }
}